package casts.home
{
   import command.DoTweenMax;
   
   import flash.events.Event;
   
   import jp.progression.casts.CastMovieClip;

   /**
    * @author cjboy1984@gmail.com
    */
   public class home_main extends CastMovieClip
   {

      public function home_main(initObject:Object = null)
      {
         super(initObject);

         //id = '';
         group = 'home';

         stop();
      }

      // --------------------- LINE ---------------------

      // ################### protected ##################

      override protected function atCastAdded():void
      {
         // basic
         onStageResize();
         stage.addEventListener(Event.RESIZE, onStageResize);

         // animation
         alpha = 0;
         addCommand(
            new DoTweenMax(this, 0.4, { alpha:1 } )
         );
      }

      override protected function atCastRemoved():void
      {
         if (stage) stage.removeEventListener(Event.RESIZE, onStageResize);

         addCommand(
            new DoTweenMax(this, 0.2, { alpha:0 } )
         );
      }

      // #################### private ###################

      // --------------------- LINE ---------------------

      private function onStageResize(e:Event = null):void
      {
         x = orgX;
         y = orgY;
      }

      // Original x,y-pos
      private function get orgX():Number { return sw / 2; }
      private function get orgY():Number { return sh / 2; }

      private function get sw():Number { return stage.stageWidth; }
      private function get sh():Number { return stage.stageHeight; }

      // --------------------- LINE ---------------------

   }

}
